package com.woniuxy01;

/**
 * @author 作者
 * @create 2025-07-25 14:07
 */
interface MyInterface {
    //接口做计算
    int calc(int a, int b);
}

class Ccc{
    public int getResult(int a, int b,MyInterface myInterface){
        return myInterface.calc(a,b);
    }
}

class MyInterfaceAdd implements MyInterface{
    //接口的实现类，实现加法计算
    public int calc(int a, int b){
        return a+b;
    }
}

public class Bbb {
    public static void main(String[] args) {
        Ccc ccc = new Ccc();
        System.out.println(ccc.getResult(1, 2, new MyInterfaceAdd()));
        System.out.println(ccc.getResult(1, 2, new MyInterface() {
            @Override
            public int calc(int a, int b) {
                return a-b;
            }
        }));

        MyInterface myInterfaceMul = new MyInterface() {
            @Override
            public int calc(int a, int b) {
                return a*b;
            }
        };
        System.out.println(ccc.getResult(1, 2, myInterfaceMul));

        System.out.println(ccc.getResult(1, 2, (a, b) -> a/b));
    }
}
